<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>处理用户的登录请求</title>
  </head>
  <body>
    <%
      //post请求如果出现中文乱码
      //设置请求的字符编码
      request.setCharacterEncoding("UTF-8");
      String userName=request.getParameter("userName"); 
      String userPwd=request.getParameter("userPwd");
      //判断用户名和密码
      if("admin".equals(userName) && "0".equals(userPwd)){
        //用户名和密码正确，页面重定向到后台首页
        //response.sendRedirect("../manage/index.jsp");
        
        //用户名和密码正确，页面转发到后台首页
        request.getRequestDispatcher("../manage/index.jsp").forward(request, response);
        
      }else{
        //用户名和密码不正确,出现弹框提示信息，之后页面跳转到前台首页
        out.println("<script>alert('用户名和密码不正确');location.href='../index.jsp';</script>");
      }  
    %>
    <h1>用户的登录信息如下：</h1>
    <h2>用户名：<%=userName %></h2>
    <h2>密码：<%=userPwd %></h2>
  </body>
</html>
